package tgc.edu.tms.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIgnore;

import tgc.edu.tms.custom.BaseEntity;
/***
 * 
 * 班级表
 *
 */
@Entity
public class TbClass extends BaseEntity<Integer>{
	private String name;	//班级名字
	private Integer number;//班级人数
	private Profession profession;
	@JsonIgnore
	private List<ClassSchedule> schedule=new ArrayList<>();//对应生成的课程表 ClassSchedule表
	@JsonIgnore
	private List<Student> student=new ArrayList<>();//对应生成学生表Student
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public Integer getNumber() {
		return number==null?0:number;
	}
	public void setNumber(Integer number) {
		this.number = number;
	}
	@ManyToOne
	public Profession getProfession() {
		return profession;
	}
	public void setProfession(Profession profession) {
		this.profession = profession;
	}

	
	@OneToMany(mappedBy="tbClass",cascade=CascadeType.ALL)
	public List<Student> getStudent() {
		return student;
	}
	public void setStudent(List<Student> student) {
		this.student = student;
	}
	@Transient//非持久化年级
	public String getYear() {
		return profession==null?null:profession.getYear();
	}
	@Transient//非持久化专业
	public String getProfesion() {
		return profession==null?null:profession.getProfesion();
	}
}
